package demo2;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ASUS
 * Date: 2023-11-28
 * Time: 19:56
 */
class Account {
    private int id ;
    private double number;
    private String name;
    public void Account(int id, double number, String name) {
        this.id = id;
        this.number = number;
        this.name = name;

    }
    public void print() {
        System.out.println("你的账户名：" + this.name + "  银行卡号：" + this.id + "  金额为:" + this.number);
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getNumber() {
        return number;
    }

    public void setNumber(double number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Account{" +
                "id=" + id +
                ", number=" + number +
                ", name='" + name + '\'' +
                '}';
    }
    public void Exit(){
        System.out.println("退出系统！");
    }

    public void Inquire(){
        setNumber(999.99);
        System.out.println("你的账户余额为："+this.number);
    }
    public void Deposit(){
        Scanner sc = new Scanner(System.in);
        System.out.println("你需要存储的金额为:");
        double number1 = sc.nextDouble();
        System.out.println("存款成功！");
        System.out.println("余额为："+(this.number+number1));
    }
    public void Withdrawal(){
        Scanner sc = new Scanner(System.in);
        System.out.println("你需要取出的金额为:");
        double number2 = sc.nextDouble();
        System.out.println("取款成功！");
        System.out.println("余额为："+(this.number-number2));
    }
    public void TransferAccounts(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入转账人的银行卡号：");
        int id3 = sc.nextInt();
        System.out.println("请输入转账人的账户名：");
        String name3 = sc.next();
        System.out.println("你需要转账的金额为:");
        double number3 = sc.nextDouble();
        System.out.println("转账成功！");
        System.out.println("你的余额为："+(this.number-number3));
    }
}
class Menu {
        public  void Menu(){
            System.out.println("   系统开启!");
            System.out.println("   ********************");
            System.out.println("   ****银行存取款系统*****");
            System.out.println("   ********************");

            System.out.println("请选择你需要办理的业务：");
            System.out.println("1.余额查询   2.存款");
            System.out.println("3.取款      4.转账");
            System.out.println("0.退出系统");
        }
    }
class Operation extends Account {
    public void Choose(){
        Operation operation = new Operation();
        boolean flag = true;
        while (flag){
            System.out.println("请选择你要进行的操作->");
            Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            switch (a){
                case 0:
                    operation.Exit();
                    flag = false;
                    break;
                case 1:
                    operation.Inquire();
                    break;
                case 2:
                    operation.Deposit();
                    break;
                case 3:
                    operation.Withdrawal();
                    break;
                case 4:
                   operation.TransferAccounts();
                    break;
            }
        }
        System.out.println("如果需要再次操作请重新运行程序！");
    }
}

public class BankAccount {

    public static void main(String[] args) {
        Account account = new Account();
        account.Account(123456,999.99,"zjt");
        Menu menu = new Menu();
        account.print();
        menu.Menu();
        Operation operation = new Operation();
        operation.Choose();
    }
}
